package com.luoke.result;

import com.luoke.constant.StatusConstant;
import com.luoke.pojo.dto.BagDTO;
import com.luoke.pojo.dto.BattleInfoDTO;
import com.luoke.pojo.dto.BattleRoundDTO;
import com.luoke.pojo.entity.Pet;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T>  implements Serializable {

    /**
     * 指令   子模块名
     */
    private String command;

    /**
     * 模块名
     */
    private String moduleName;

    /**
     * 响应转态
     */
    private String status;

    /**
     * 提示信息
     */
    private String message;
    /**
     * 请求用户
     */
    private String fromUser;
    /**
     * 目标用户
     */
    private String toUser;

    /**
     * 具体的响应数据
     */
    private T data;

    /**
     * 当前宠物
     */
    private List<Pet> currentPet;
    /**
     * 当前背包
     */
    private List<BagDTO> currentBag;

    /**
     * 响应成功的情况
     */
    public static <T> Result<T> success(String command, String moduleName, String message, T object) {
        Result<T> result = new Result<>();
        result.command = command;
        result.moduleName = moduleName;
        result.message = message;
        result.status = StatusConstant.SUCCESS;
        result.data = object;
        return result;
    }



    /**
     * 响应成功的情况    无数据对象
     */
    public static <T> Result<T> success(String command, String moduleName, String message) {
        Result<T> result = new Result<>();
        result.command = command;
        result.moduleName = moduleName;
        result.message = message;
        result.status = StatusConstant.SUCCESS;
        return result;
    }


    /**
     * 响应成功的情况    无数据对象，无信息
     */
    public static <T> Result<T> success(String command, String moduleName) {
        Result<T> result = new Result<>();
        result.command = command;
        result.moduleName = moduleName;
        result.status = StatusConstant.SUCCESS;
        return result;
    }


    /**
     * 响应失败的情况
     */
    public static <T> Result<T> fail(String command, String moduleName, String message, T object) {
        Result<T> result = new Result<>();
        result.command = command;
        result.moduleName = moduleName;
        result.message = message;
        result.status = StatusConstant.FAIL;
        result.data = object;
        return result;
    }


    /**
     * 响应失败的情况  无数据对象
     */
    public static <T> Result<T> fail(String command, String moduleName, String message) {
        Result<T> result = new Result<>();
        result.command = command;
        result.moduleName = moduleName;
        result.message = message;
        result.status = StatusConstant.FAIL;
        return result;
    }

    /**
     * 响应失败的情况  无数据对象 无信息
     */
    public static <T> Result<T> fail(String command, String moduleName) {
        Result<T> result = new Result<>();
        result.command = command;
        result.moduleName = moduleName;
        result.status = StatusConstant.FAIL;
        return result;
    }
}

